#include"MonsterGroup.h"
#include"GameMonster.h"
#include"ConfigParser.h"
#include"../Common.h"
#include"../utils/GameUtils.h"

MonsterGroup::MonsterGroup()
{
	
}

MonsterGroup::~MonsterGroup()
{
}

int MonsterGroup::getId()
{
	return m_id;
}

void MonsterGroup::init(const int& id, const int& sceneId)
{
	m_id = id;
	m_sceneId = sceneId;
	initMonster(sceneId);
}

std::list<GameMonster>* MonsterGroup::getMonsterList()
{
	return &m_monsterList;
}

int MonsterGroup::getSceneId()
{
	return m_sceneId;
}

void MonsterGroup::initMonster(const int& sceneId)
{
	m_sceneId = sceneId;
	auto data = ConfigParser("scene_monster.json").get(std::to_string(sceneId));
	for (int i = 1; i <= MAX_SCENE_MONSTER; ++i)
	{
		auto monsterId = data["monster_" + std::to_string(i)].asInt();
		auto posStr = data["reborn_pos_" + std::to_string(i)].asCString();
		auto posArr = GameUtils::split(posStr, "|");
		Myvec pos(std::stof(posArr[0]), std::stof(posArr[1]), std::stof(posArr[2]));
		GameMonster monster(monsterId, pos);
		m_monsterList.push_back(monster);
	}
}
